<?php 
/**
 *  
 * 
 * @name send_admins.php
 * @author Jerome Vigne
 */
class Send_admins extends CI_Controller 
{
	function Send_admins() {
        parent::__construct();
        //Chargement du model
		$this->load->model('accueil_model');
		//Chargement du helper form	    
        $this->load->helper('form');
        //Chargement de la librarie form
     }

    public function edit_home()
    {    	
        $this->load->library('form_validation');
        //Test des champs du formulaire avec des arguments
        $this->form_validation->set_rules('title', 'title', 'required');
		$this->form_validation->set_rules('text', 'text', 'required');
		$this->form_validation->set_rules('signature', 'signature', 'required');
		
		if ($this->form_validation->run() == FALSE)
		{
			$this->load_page('Veuillez renseigner l\'ensemble des champs !', null, 'Slide1.jpg', 'private/accueilp', $this->accueil_model->get_info());
		}
		else
		{
			$data = array(
				'title' =>$this->input->post('title'),
				'text' =>$this->input->post('text'),
				'signature' =>$this->input->post('signature'));
			
			$edit = $this->accueil_model->modif_info($data);
			if ($edit == TRUE){
				$this->load_page(null, 'Modification ok !', 'Slide1.jpg', 'private/accueilp', $this->accueil_model->get_info());
			}       
		}
    }
    
    public function load_page($erreur, $info, $image, $content, $da) 
    {
    	$data['erreur'] = $erreur;
		$data['info'] = $info;
		$data['image'] = $image;
		$data['content'] = $content;
		$data['data'] = $da;
        $this->load->view('layout/build/body', $data);
    }
    	
}